package cn.hfgf.springmvc.service.impl;

import cn.hfgf.springmvc.dal.dao.TUserMapper;
import cn.hfgf.springmvc.dal.model.TUser;
import cn.hfgf.springmvc.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author wangxuekai
 * @version 2.0
 * @Date 2017/1/16.
 * @since 2.0
 */
@Service("userService")
public class UserServiceImpl implements UserService {
    private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private TUserMapper tUserMapper;

    @Override
    @Transactional
    public boolean insert(TUser tUser) {
        try {
            if (tUserMapper.insert(tUser) > 0) {
                LOGGER.info("插入数据库成功");
                int i = 1/0;
                return true;
            } else {
                LOGGER.info("插入数据库失败!");
                return false;
            }
        } catch (Exception e) {
            LOGGER.info("插入数据库异常!error{}",e.getMessage(),e);
            throw new RuntimeException(e);
        }
    }

    @Override
    public boolean login(String userName, String pwd) {
        //todo 实现登陆
        return false;
    }
}
